import store from '../store/index.js';

const service = (method) => {
	return (url) => {
		return (params) => {
			return new Promise((resolve, reject) => {
				uni.request({
					url: `https://zhatu.deqing.gov.cn/muck${url}`, //真实环境
					// url: `http://101.68.86.229:8881${url}`,  //测试环境
					method,
					header: {
						Authorization: store.state.mdApprove.token,
					},
					data: params,
					success: res => {
						// console.log('*********桃仁请求: ', res)
						 if (res.data.code == 200) {
							resolve(res.data.data)
						} else {
							reject(res)
						}
					},
					fail: err => {
						// console.log('失败*********桃仁请求: ', res)
						reject(err)
					}
				})
			})
		}
	}
}

const get = service('get')
const post = service('post')

export {
	get,
	post
}
